#ifndef __MIDDLE_MIDDLEWARE_HPP
#define __MIDDLE_MIDDLEWARE_HPP
#include <map>
#include <string>

namespace middle {

  // XXX エセ実装
  class Environment {
  private:
    typedef std::map<std::string, std::string>  env_map;
    env_map values;

  public:
    void set(const std::string& key, const std::string& value) {
      this->values.insert(env_map::value_type(key, value));
    }

    std::string get(const std::string& key, const std::string& def) const {
      env_map::const_iterator it = values.find(key);
      if (it != values.end()) {
        return it->second;
      } else {
        return def;
      }
    }
  };

  class Middleware {
  public:
    virtual ~Middleware() {}
    virtual std::string call(Environment& env/*, functor& start_response*/) = 0;
  };
}

#endif
